﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using qltscd.Helper;
using qltscd.Contansts;

namespace qltscd.Controllers
{
    public class BaseController : Controller
    {
        protected override void OnActionExecuting (ActionExecutingContext filterContext) {
            if (filterContext.ActionDescriptor.ControllerDescriptor.ControllerName != "Login") {
                if (!SessionHelper.IsLogin()) {
                    filterContext.Result = RedirectToAction("index", "dangnhap");
                    ViewData[SessionConstants.ERROR_MESSAGE] = "";
                } else {
                    string tmp = (string)Session[SessionConstants.ERROR_MESSAGE];
                    ViewData[SessionConstants.ERROR_MESSAGE] = tmp;
                    Session[SessionConstants.ERROR_MESSAGE] = string.Empty;
                }
            }
        }
    }
}
